import java.util.Arrays;
import java.util.Scanner;

public class Main {
    //滑动窗口
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n= scanner.nextInt();
        int k=scanner.nextInt();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=scanner.nextInt();
        }
        int left=0;
        int right=0;
        int sum=0;
        int len=0;
        for(;right<=n-1;right++) {
            if(nums[right]==0)sum++;
            while (sum>k)
                if(nums[left++]==0) sum--;
            len=Math.max(len,right-left+1);

        }
        System.out.println(len);
    }
    public static void main6(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n= scanner.nextInt();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=scanner.nextInt();
        }
        int left=0;
        int right=0;
        int len=0;
        int lenMax=0;
        for(;right<=n-1;right++){
            len++;
            if(nums[right]==0) {
                len--;
                lenMax=len>lenMax?len:lenMax;
                right++;
                if(right>n-1) break;
                while (nums[right]==0&&(right<=n-1)){
                    right++;
                }
            }
            else lenMax=len>lenMax?len:lenMax;
        }
        System.out.println(lenMax);
    }
    public static void main3(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String str=scanner.nextLine();
        int n= str.length();
        int len=0;
        int lenMax=0;
        int left=0;
        int right=0;
        int[] has=new int[128];
        for(;right<=n-1;right++) {
            has[str.charAt(right)]++;
            len++;
            while (has[str.charAt(right)]>1) {
                has[str.charAt(left)]--;
                left++;
                len--;
            }
            lenMax=len>lenMax?len:lenMax;
        }
        System.out.println(lenMax);

        }

    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] matrix = new int[n][n];
        int num = 1;
        int row = 0;
        int col = n / 2;

        while (num <= n * n) {
            matrix[row][col] = num++;

            int newRow = (row - 1 + n) % n;
            int newCol = (col + 1) % n;

            if (matrix[newRow][newCol] != 0) {
                row = (row + 1) % n;
            } else {
                row = newRow;
                col = newCol;
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                System.out.printf("%-4d", matrix[i][j]);
            }
            System.out.println();
        }
    }
}